|
1
|
|
|
var assert = require('chai').assert, |
|
2
|
|
|
GedcomX = require('../'); |
|
3
|
|
|
|
|
4
|
|
|
describe('PlaceReference', function(){ |
|
5
|
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
|
7
|
|
|
var newRef = new GedcomX.PlaceReference(), |
|
8
|
|
|
ref = GedcomX.PlaceReference(); |
|
9
|
|
|
assert.instanceOf(newRef, GedcomX.PlaceReference, 'An instance of PlaceReference is not returned when calling the constructor with new.'); |
|
10
|
|
|
assert.instanceOf(ref, GedcomX.PlaceReference, 'An instance of PlaceReference is not returned when calling the constructor without new.'); |
|
11
|
|
|
}); |
|
12
|
|
|
|
|
13
|
|
|
it('Create with JSON', function(){ |
|
14
|
|
|
var ref = GedcomX.PlaceReference({ |
|
15
|
|
|
id: 'ref', |
|
16
|
|
|
original: 'Miami, Missouri', |
|
17
|
|
|
description: 'http://place/description' |
|
18
|
|
|
}); |
|
19
|
|
|
assert.equal(ref.getId(), 'ref'); |
|
20
|
|
|
assert.equal(ref.getOriginal(), 'Miami, Missouri'); |
|
21
|
|
|
assert.equal(ref.getDescription(), 'http://place/description'); |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
|
it('Build', function(){ |
|
25
|
|
|
var ref = GedcomX.PlaceReference() |
|
26
|
|
|
.setId('ref') |
|
27
|
|
|
.setOriginal('Miami, Missouri') |
|
28
|
|
|
.setDescription('http://place/description'); |
|
29
|
|
|
assert.equal(ref.getId(), 'ref'); |
|
30
|
|
|
assert.equal(ref.getOriginal(), 'Miami, Missouri'); |
|
31
|
|
|
assert.equal(ref.getDescription(), 'http://place/description'); |
|
32
|
|
|
}); |
|
33
|
|
|
|
|
34
|
|
|
it('toJSON', function(){ |
|
35
|
|
|
var data = { |
|
36
|
|
|
id: 'ref', |
|
37
|
|
|
original: 'Miami, Missouri', |
|
38
|
|
|
description: 'http://place/description' |
|
39
|
|
|
}, ref = GedcomX.PlaceReference(data); |
|
40
|
|
|
assert.deepEqual(ref.toJSON(), data); |
|
41
|
|
|
}); |
|
42
|
|
|
|
|
43
|
|
|
it('constructor does not copy instances', function(){ |
|
44
|
|
|
var obj1 = GedcomX.PlaceReference(); |
|
45
|
|
|
var obj2 = GedcomX.PlaceReference(obj1); |
|
46
|
|
|
assert.strictEqual(obj1, obj2); |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
|
}); |